package com.meng.demo1;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @Author: menglinggang
 * @Date: 2020-06-23
 * @Time: 下午5:13
 */
public class ComponentContainer extends Component {

    private List<Component> components;

    public ComponentContainer(String name) {
        super.name = name;
        components = new ArrayList<Component>();
    }

    public void addComponent(Component component){
        components.add(component);
    }

    @Override
    public void doPrint() {
        System.out.println("print : " + name);
        for (Component component : components) {
            component.doPrint();
        }
    }
}
